package org.dftproject.genesis.data.genealogy.impl;

import java.util.Collections;
import java.util.LinkedList;
import java.util.List;

import org.dftproject.genesis.data.genealogy.IName;
import org.dftproject.genesis.data.genealogy.INamePart;
import org.dftproject.genesis.data.impl.EntityImpl;

public class NameImpl extends EntityImpl implements IName {
	
	private final List<INamePart> nameParts = new LinkedList<INamePart>();
	
	public NameImpl() {
	}
	
	public NameImpl(String name) {
		for (String part : name.split("\\s+"))
			nameParts.add(new NamePartImpl(part));
	}
	
	@Override
	public String toString() {
		return nameParts.toString();
	}

	public List<INamePart> getNameParts() {
		return Collections.unmodifiableList(nameParts);
	}
	
	public void add(INamePart namePart) {
		nameParts.add(namePart);
	}

}
